import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;

class DisplayContainer
{
	private JFrame display;
	private GraphicsDevice gd;
	private DisplayMode availibleModes[];
	
	public DisplayContainer()
	{
		display = new JFrame();
		display.setUndecorated(true);
		
		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
		gd = ge.getDefaultScreenDevice();
	}
	
//	STUFF DOESN'T WORK - CANNOT CHANGE DISPLAY MODE?? POSSIBLY PROBLEM WITH DEFAULT GRAPHICS DEVICE
//		availibleModes = gd.getDisplayModes();
//	}
//	
//	public DisplayMode[] getAvailibleModes()
//	{
//		return availibleModes;
//	}
//	
//	public void setDisplayMode(DisplayMode dm)
//	{
//		for(int x = 0; x < availibleModes.length; x++)
//			if(dm == availibleModes[x])
//				gd.setDisplayMode(dm);
//	}
	
	
	public void setFullscreen(boolean b)
	{
		if(b)
			gd.setFullScreenWindow(display);
		else
			gd.setFullScreenWindow(null);
	}
	
	public void setDisplay(JPanel panel)
	{
		display.setContentPane(panel);
	}
	
	public void setOverlay(JPanel panel)
	{
		display.setGlassPane(panel);
	}
	
	public void setKeyListener(KeyListener kl)
	{
		if(display.getKeyListeners().length != 0)
			display.removeKeyListener(display.getKeyListeners()[0]);
		display.addKeyListener(kl);
	}
	
	public void setMouseListener(MouseAdapter ml)
	{
		if(display.getMouseListeners().length != 0)
		{
			display.removeMouseListener(display.getMouseListeners()[0]);
			display.removeMouseMotionListener(display.getMouseMotionListeners()[0]);
		}
		display.addMouseListener(ml);
		display.addMouseMotionListener(ml);
	}
}